<?php
namespace Home\Controller;
use Think\Controller;

class BuyController extends BaseController {
  
    public function buy(){


      $sellerModel=M('seller');//表明,conf中定义前缀
      //$userModel=M('users');
    /*  $username=session('username');
     */
      $seller= $sellerModel->order('sellerid asc')->select(); //desc降序 asc升序
      $this->buylist=$seller;//name属性对应的值 $this->对应值=$goods;

      $this->display();
  

    } 








  
    public function type(){
      $toys_type=$_GET['toys_type'];

      $sellerModel=M('seller');//表明,conf中定义前缀
      //$userModel=M('users');
    /*  $username=session('username');
     */
      $seller= $sellerModel->where("toys_type=$toys_type")->order('sellerid asc')->select(); //desc降序 asc升序
      $this->typelist=$seller;//name属性对应的值 $this->对应值=$goods;

      $this->display();
  

    } 

 




   public function order(){

        $data=$_POST;
       dump($data);

          $sellerModel = M('orderlist'); 
     
        $createresult=$sellerModel->create();   // 根据表单提交的POST数据创建数据对象
          if ($createresult) {
             
                $sellerModel->userid = $_SESSION['user_id'];
                $sellerModel->toys_name= trim(I('post.product_title:'));
                $sellerModel->money = trim(I('post.product_price'));
               $sellerModel->createtime =  date("Y-m-d H:i:s"); // 设置用户的创建时间
       
             $addresult=$sellerModel->add(); // 写入用户数据到数据库
                     if (false !== $addresult)
                             {
                            $this->success('添加成功！', '../Index/index');
                             }else{ 
                                     $this->error('数据错误'); 
                                   }

        }else{
                $this->error($sellerModel->getError());  
              }


    }
        

  


}